package com.example.io;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @Author 尚智江
 * @description
 * @CreateDate 2024/1/8 23:13
 */
public class FileByCopy {
    public static void main(String[] args) throws IOException {
        /*
        文件拷贝
        边读边写
         */

        FileInputStream fileInputStream = new FileInputStream("C:\\Users\\28593\\Desktop\\edd346e979577f5ee831130f2c0d48ba.png");
        FileOutputStream outputStream = new FileOutputStream("E:\\SpringBoot\\Spring-Boot\\java-io\\src\\main\\resources\\a.png");

        int b;
        while ((b = fileInputStream.read()) != -1){
            outputStream.write(b);
        }

        // 先开 后关
        outputStream.close();
        fileInputStream.close();

    }
}
